package org.dark.fund.interceptor;

import lombok.extern.slf4j.Slf4j;
import org.apache.skywalking.apm.toolkit.trace.TraceContext;
import org.springframework.lang.Nullable;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 对Spring Mvc 的请求拦截, 添加traceId.
 *
 * @author mashu
 */

@Slf4j
public class SpringMvcTraceFilter implements HandlerInterceptor {


    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, @Nullable Exception ex) throws Exception {
        log.info("sky traceId: {}", TraceContext.traceId());
    }

}
